package io.renren.modules.biz.controller;

import java.util.Arrays;
import java.util.Map;

import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import io.renren.modules.biz.entity.BizKlineEntity;
import io.renren.modules.biz.service.BizKlineService;
import io.renren.common.utils.PageUtils;
import io.renren.common.utils.R;

/**
 * K线图
 *
 * @author xiaoqi
 * @email xiaoqi.gd@gmail.com
 * @date 2018-10-14 15:47:16
 */
@RestController
@RequestMapping("biz/bizkline")
public class BizKlineController {
	
	@Autowired
	private BizKlineService bizKlineService;

	/**
	 * 列表
	 */
	@RequestMapping("/list")
	@RequiresPermissions("biz:bizkline:list")
	public R list(@RequestParam Map<String, Object> params) {
		PageUtils page = bizKlineService.queryPage(params);
		return R.ok().put("page", page);
	}

	/**
	 * 信息
	 */
	@RequestMapping("/info/{id}")
	@RequiresPermissions("biz:bizkline:info")
	public R info(@PathVariable("id") Integer id) {
		BizKlineEntity bizKline = bizKlineService.selectById(id);
		return R.ok().put("bizKline", bizKline);
	}

	/**
	 * 保存
	 */
	@RequestMapping("/save")
	@RequiresPermissions("biz:bizkline:save")
	public R save(@RequestBody BizKlineEntity bizKline) {
		bizKlineService.insert(bizKline);
		return R.ok();
	}

	/**
	 * 修改
	 */
	@RequestMapping("/update")
	@RequiresPermissions("biz:bizkline:update")
	public R update(@RequestBody BizKlineEntity bizKline) {
		bizKlineService.updateById(bizKline);
		return R.ok();
	}

	/**
	 * 删除
	 */
	@RequestMapping("/delete")
	@RequiresPermissions("biz:bizkline:delete")
	public R delete(@RequestBody Integer[] ids) {
		bizKlineService.deleteBatchIds(Arrays.asList(ids));
		return R.ok();
	}

}
